{% extends "base.html" %}
{% load	bootstrap3 %}
{% load i18n %}
{% load static %}

{% block  title %}{% trans 'Audits' %}{% endblock %}

{% block page-content %}
    <div class="row wrapper border-bottom white-bg page-heading">
        <div class="col-lg-10">
            <h2>{% trans 'Audits' %}</h2>
            <ol class="breadcrumb">
                <li>
                     <a href="/">{% trans 'Home' %}</a>
                </li>
                <li>
                    <a>{% trans 'Audits' %}</a>
                </li>
                <li class="active">
                    <strong>{% trans 'Login Log' %}</strong>
                </li>
            </ol>
        </div>
        <div class="col-lg-2">

        </div>
    </div>
    <div class="wrapper wrapper-content animated fadeInRight   ">
        <div class="row">

            <div class="col-lg-12" id="split-right">

                <div class="ibox float-e-margins">

                    <div class="ibox-title">
                        <h5>{% trans 'Audits' %}</h5>
                        <div class="ibox-tools">
                            <a class="collapse-link">
                                <i class="fa fa-chevron-up"></i>
                            </a>
                            <a class="dropdown-toggle" data-toggle="dropdown" href="#">
                                <i class="fa fa-wrench"></i>
                            </a>
                            <ul class="dropdown-menu dropdown-user">
                                <li><a href="#" >{% trans 'Config Option 1' %}</a>
                                </li>
                                <li><a href="#" >{% trans 'Config Option 2' %}</a>
                                </li>
                            </ul>
                            <a class="close-link">
                                <i class="fa fa-times"></i>
                            </a>
                        </div>
                    </div>
                    <div class="ibox-content">

                        <div class="table-responsive">

                            <div class="col-lg-6" style="padding-left:0px">
                                <form id="date_form">
                                    {% csrf_token %}
                                    <div class="pull-left"><input type="text" class="form-control" name="name" placeholder="{% trans 'User Name' %}"> </div>
                                    <div class="input-group col-lg-offset-3">
                                        <span class="add-on input-group-addon"><i class="glyphicon glyphicon-calendar fa fa-calendar"></i></span>
                                        <input type="text" name="date_from" class="form-control" placeholder="选择开始日期" id="datetimepicker1">
                                        <span class="add-on input-group-addon"><i class="glyphicon glyphicon-calendar fa fa-calendar"></i></span>
                                        <input type="text" name="date_to" class="form-control" placeholder="选择结束日期" id="datetimepicker2">

                                    </div>
                                </form>
                            </div>
                            <div class="input-group-btn">
                                <button type="submit" class="btn btn-primary" form="date_form">查询</button>
                            </div>
                            <form id="del_form_asset_all" class="form-horizontal" action="" method="post">
                                {% csrf_token %}
                                <table class="table table-striped table-bordered table-hover dataTables-asset">
                                    <thead>
                                    <tr>
                                        <th>{% trans 'Number' %}</th>
                                        <th>{% trans 'User Name' %}</th>
                                        <th>{% trans 'Remote ipaddr' %}</th>
                                        <th>{% trans 'DateTime' %}</th>
                                        <th>{% trans 'Action' %}</th>
                                    </tr>
                                    </thead>
                                    <tbody>

                                    {% for row in loginlog_list.object_list %}
                                        <tr class="gradeA" id="{{ row.id }}">
                                        <td>{{forloop.counter}}</td>
                                        <td>{{ row.username.username }}</td>
                                        <td>{{ row.ipaddr }}</td>
                                        <td>{{ row.datetime|date:"Y-m-d H:i:s" }}</td>
                                        {% ifequal row.get_full_path '/users/login/' %}
                                            <td>{% trans 'Login' %}</td>
                                        {% else %}
                                            <td>{% trans 'Logout' %}</td>
                                        {% endifequal %}
                                    </tr>
                                    {% endfor %}
                                    </tbody>

                                </table>
                                <div class="pull-right">
                                     <nav class="pagination">
                                     <li><a href="{% url "audit:login-log-list" %}?page=1">{% trans 'Home' %}</a></li>

                                        {% if loginlog_list.has_previous %}
                                            <li class="long"><a href="?{{ loginlog_list.previous_page_number.querystring }}">{% trans 'Home' %}</a></li>
                                        {% endif %}

                                        {% for page in loginlog_list.pages %}
                                        {% if page %}
                                            {% ifequal page loginlog_list.number %}
                                                <li class="active"><a href="?{{ page.querystring }}">{{ page }}</a></li>
                                            {% else %}
                                                 <li><a href="?{{ page.querystring }}" class="page">{{ page }}</a></li>
                                            {% endifequal %}
                                        {% else %}
                                            <li class="none"><a href="">...</a></li>
                                        {% endif %}
                                        {% endfor %}
                                        {% if loginlog_list.has_next %}
                                            <li class="long"><a href="?{{ loginlog_list.next_page_number.querystring }}">{% trans 'Next' %}</a></li>
                                        {% endif %}
                                        <li>
                                            <a href="{% url "audit:login-log-list" %}?page={{ loginlog_list.paginator.num_pages }}">{% trans 'Trailer' %}</a>
                                        </li>
                                        <li><span style="color: #0a0a0a">{% trans 'Total' %}: &nbsp;{{ loginlog_list.paginator.num_pages }} {% trans 'Page' %}</span>
                                        </li>
                                    </nav>
                                </div> <!--页码 -->
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>



{% endblock %}
{% block footer-js %}
    <script>
        $('#datetimepicker1').datetimepicker({
                onGenerate:function( ct ){
                $(this).find('.xdsoft_date.xdsoft_weekend')
                //      .addClass('xdsoft_disabled');
        },
        weekends:['01.01.2014','02.01.2014','03.01.2014','04.01.2014','05.01.2014','06.01.2014'],
        yearOffset:0,
        lang:'ch',      //中文显示
        timepicker:false,
        format:'Y-m-d',         //格式年月日
        formatDate:'Y-m-d',
    });

    $('#datetimepicker2').datetimepicker({
                onGenerate:function( ct ){
                $(this).find('.xdsoft_date.xdsoft_weekend')
                //      .addClass('xdsoft_disabled');
        },
        weekends:['01.01.2014','02.01.2014','03.01.2014','04.01.2014','05.01.2014','06.01.2014'],
        yearOffset:0,
        lang:'ch',      //中文显示
        timepicker:false,
        format:'Y-m-d',         //格式年月日
        formatDate:'Y-m-d',
    });
    </script>
{% endblock %}
{% block footer-js-ajax %}
{% endblock %}